package acm.力扣391周赛;

import java.util.Arrays;

public class 最小化曼哈顿距离 {
    /**
     * 暴力解：枚举所有点，移除该点后求一次所有点到所有点的最大值
     * 时间复杂度：n^3
     *
     * @return
     */
    public int minimumDistance(int[][] points) {
        int n = points.length;
        Arrays.sort(points,(o1,o2)-> (o1[0]+o1[1])-(o2[0]+o2[1]));
        int removeH=Math.abs((points[n -1][0]-points[1][0]))+Math.abs((points[n -1][1]-points[1][1]));
        int removeT=Math.abs((points[n -2][0]+points[n -2][1]))-Math.abs((points[0][0]+points[0][1]) );
        return Math.min(removeT,removeH);
    }

}
